﻿CREATE PROCEDURE [Users_update]
	@P_1 Int,
	@P_2 NVarChar(50),
	@P_3 NVarChar(50),
	@P_4 NVarChar(max),
	@P_5 DateTime,
	@P_6 Int,
	@P_7 Bit,
	@P_8 Bit,
	@P_9 DateTime,
	@P_10 NVarChar(50),
	@P_11 DateTime,
	@P_12 NVarChar(max),
	@P_13 Int,
	@sync_force_write Int,
	@sync_min_timestamp BigInt,
	@sync_row_count Int OUTPUT
AS
BEGIN
SET @sync_row_count = 0; UPDATE [Users] SET [Username] = @P_2, [Email] = @P_3, [AccessToken] = @P_4, [Expires] = @P_5, [RoleID] = @P_6, [UserActivated] = @P_7, [UserBlocked] = @P_8, [DateTimeStamp] = @P_9, [Locale] = @P_10, [DateTimeUpdated] = @P_11, [SessionKey] = @P_12, [Version] = @P_13 FROM [Users] [base] JOIN [Users_tracking] [side] ON [base].[UserID] = [side].[UserID] WHERE ([side].[local_update_peer_timestamp] <= @sync_min_timestamp OR @sync_force_write = 1) AND ([base].[UserID] = @P_1); SET @sync_row_count = @@ROWCOUNT;
END